package com.yang.dao;

import com.yang.entity.Deposit;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 充值表(Deposit)表数据库访问层
 *
 * @author yangdacheng
 * @since 2022-03-02 19:11:02
 */
@Mapper
@Repository
public interface DepositDao {


    /**
     * 添加新的充值类型
     * @param deposit
     * @return
     */
    @Insert("INSERT INTO deposit " +
            "VALUES (#{depositID},#{depositMoney},#{depositNumber},#{depositShow})")
    Boolean insertDeposit(Deposit deposit);

    /**
     * 修改充值类型
     * @param deposit
     * @return
     */
    @Update("UPDATE deposit SET " +
            "depositShow = #{depositShow},depositMoney=#{depositMoney}," +
            "depositNumber=#{depositNumber}" +
            "WHERE depositID = #{depositID}")
    Boolean updateDeposit(Deposit deposit);

    /**
     * 根据编号删除充值类型
     * @param depID
     * @return
     */
    @Delete("DELETE FROM deposit WHERE depositID = #{depID}")
    Boolean deleteDeposit(String depID);

    /**
     * 查询所有的充值列席
     * @return
     */
    @Results(value = {
            @Result(column = "depositID",property = "depositID",id = true),
            @Result(column = "depositMoney",property = "depositMoney"),
            @Result(column = "depositNumber",property = "depositNumber"),
            @Result(column = "depositShow",property = "depositShow"),
    },id = "depMapper")
    @Select("SELECT * FROM deposit WHERE depositShow = #{isShow}")
    List<Deposit> queryAllDeposit(Integer isShow);

    /**
     * 根据充值编号查询充值
     * @param depID
     * @return
     */
    @ResultMap(value = "depMapper")
    @Select("SELECT * FROM deposit WHERE depositID = #{depID}")
    Deposit queryDepositByID(String depID);
}